.class public Lcom/glympse/platform/common/ZendeskJob;
.super Lcom/glympse/platform/common/HttpJob;
.source "ZendeskJob.java"


# instance fields
.field private m_nAttempts:I

.field private m_nContentLength:I

.field private m_strLocation:Ljava/lang/String;


# direct methods
.method public constructor <init>(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
    .locals 4
    .parameter "nRating"
    .parameter "strCategory"
    .parameter "strComment"
    .parameter "strEmail"

    .prologue
    const/4 v3, 0x0

    .line 29
    invoke-direct {p0}, Lcom/glympse/platform/common/HttpJob;-><init>()V

    .line 20
    iput v3, p0, Lcom/glympse/platform/common/ZendeskJob;->m_nAttempts:I

    .line 23
    iput v3, p0, Lcom/glympse/platform/common/ZendeskJob;->m_nContentLength:I

    .line 26
    const/4 v2, 0x0

    iput-object v2, p0, Lcom/glympse/platform/common/ZendeskJob;->m_strLocation:Ljava/lang/String;

    .line 33
    iput-boolean v3, p0, Lcom/glympse/platform/common/ZendeskJob;->m_fCompleteOnMainThread:Z

    .line 36
    const-string v2, "http://glympse.zendesk.com/requests/mobile_api/create.json"

    iput-object v2, p0, Lcom/glympse/platform/common/ZendeskJob;->m_strUrl:Ljava/lang/String;

    .line 39
    const/4 v2, 0x1

    iput-boolean v2, p0, Lcom/glympse/platform/common/ZendeskJob;->m_fPost:Z

    .line 44
    :try_start_0
    invoke-direct {p0, p1, p2, p3, p4}, Lcom/glympse/platform/common/ZendeskJob;->PrepareTicketBody(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v2

    const-string v3, "UTF-8"

    invoke-virtual {v2, v3}, Ljava/lang/String;->getBytes(Ljava/lang/String;)[B

    move-result-object v0

    .line 45
    .local v0, abPostData:[B
    array-length v2, v0

    iput v2, p0, Lcom/glympse/platform/common/ZendeskJob;->m_nContentLength:I

    .line 46
    invoke-virtual {p0, v0}, Lcom/glympse/platform/common/ZendeskJob;->SetPostData([B)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 52
    .end local v0           #abPostData:[B
    :goto_0
    return-void

    .line 48
    :catch_0
    move-exception v2

    move-object v1, v2

    .line 50
    .local v1, e:Ljava/lang/Exception;
    invoke-static {v1}, Lcom/glympse/platform/common/Helpers;->Log(Ljava/lang/Throwable;)V

    goto :goto_0
.end method

.method private PrepareDescription(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    .locals 4
    .parameter "nRating"
    .parameter "strCategory"
    .parameter "strComment"
    .parameter "strEmail"

    .prologue
    .line 72
    const/4 v1, 0x0

    .line 76
    .local v1, strDescription:Ljava/lang/String;
    :try_start_0
    new-instance v2, Ljava/lang/StringBuilder;

    const-string v3, "In-App Feedback, "

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-static {}, Lcom/glympse/platform/Platform;->GetDateTimeString()Ljava/lang/String;

    move-result-object v3

    invoke-static {v3}, Lcom/glympse/platform/common/Helpers;->SafeStr(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v3, ":\n"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    .line 77
    const-string v3, "\n"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    .line 78
    const-string v3, "UserId: "

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-static {}, Lcom/glympse/platform/Platform;->instance()Lcom/glympse/platform/Platform;

    move-result-object v3

    iget-object v3, v3, Lcom/glympse/platform/Platform;->m_oUserList:Lcom/glympse/platform/common/UserList;

    invoke-virtual {v3}, Lcom/glympse/platform/common/UserList;->GetSelf()Lcom/glympse/platform/common/User;

    move-result-object v3

    iget-object v3, v3, Lcom/glympse/platform/common/User;->m_strUserId:Ljava/lang/String;

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v3, "\n"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    .line 79
    const-string v3, "UserAgent: "

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-static {}, Lcom/glympse/platform/Platform;->instance()Lcom/glympse/platform/Platform;

    move-result-object v3

    invoke-virtual {v3}, Lcom/glympse/platform/Platform;->GetBrowserAgent()Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v3, "\n"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    .line 80
    const-string v3, "Category: "

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-static {p2}, Lcom/glympse/platform/common/Helpers;->SafeStr(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/String;->toLowerCase()Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v3, "\n"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    .line 81
    const-string v3, "Rating: "

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2, p1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v3, "\n"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    .line 82
    const-string v3, "ContactEmail: "

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2, p4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v3, "\n"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    .line 83
    const-string v3, "DeviceType: "

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-static {}, Lcom/glympse/platform/Platform;->GetDeviceInfo()Ljava/lang/String;

    move-result-object v3

    invoke-static {v3}, Lcom/glympse/platform/common/Helpers;->SafeStr(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v3, "\n"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    .line 84
    const-string v3, "Comment: "

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-static {p3}, Lcom/glympse/platform/common/Helpers;->SafeStr(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    .line 76
    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v1

    .line 90
    :goto_0
    return-object v1

    .line 86
    :catch_0
    move-exception v2

    move-object v0, v2

    .line 88
    .local v0, e:Ljava/lang/Exception;
    invoke-static {v0}, Lcom/glympse/platform/common/Helpers;->Log(Ljava/lang/Throwable;)V

    goto :goto_0
.end method

.method private PrepareTicketBody(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    .locals 4
    .parameter "nRating"
    .parameter "strCategory"
    .parameter "strComment"
    .parameter "strEmail"

    .prologue
    .line 57
    invoke-static {p4}, Lcom/glympse/platform/common/Helpers;->IsEmpty(Ljava/lang/String;)Z

    move-result v1

    if-eqz v1, :cond_0

    .line 58
    const-string p4, "noreply@glympse.com"

    .line 59
    :cond_0
    invoke-static {p2}, Lcom/glympse/platform/common/Helpers;->IsEmpty(Ljava/lang/String;)Z

    move-result v1

    if-eqz v1, :cond_1

    .line 60
    const-string p2, "Feedback"

    .line 62
    :cond_1
    new-instance v1, Ljava/lang/StringBuilder;

    const-string v2, "description="

    invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-direct {p0, p1, p2, p3, p4}, Lcom/glympse/platform/common/ZendeskJob;->PrepareDescription(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v2

    invoke-static {v2}, Lcom/glympse/platform/common/Helpers;->SafeStr(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v2

    invoke-static {v2}, Lcom/glympse/platform/Platform;->UrlEncode(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    .line 63
    const-string v2, "&email="

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-static {p4}, Lcom/glympse/platform/Platform;->UrlEncode(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    .line 64
    const-string v2, "&subject="

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    new-instance v2, Ljava/lang/StringBuilder;

    invoke-static {p2}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v3, " from "

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v3, "Android"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v3, " user"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-static {v2}, Lcom/glympse/platform/Platform;->UrlEncode(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    .line 65
    const-string v2, "&set_tags="

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    new-instance v2, Ljava/lang/StringBuilder;

    const-string v3, "Android"

    invoke-virtual {v3}, Ljava/lang/String;->toLowerCase()Ljava/lang/String;

    move-result-object v3

    invoke-static {v3}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v3, " "

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v3, "md_android"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-static {v2}, Lcom/glympse/platform/Platform;->UrlEncode(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    .line 62
    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    .line 66
    .local v0, strBody:Ljava/lang/String;
    return-object v0
.end method


# virtual methods
.method public AddRequestHeaders(Lcom/glympse/platform/GHttpConnection;)V
    .locals 3
    .parameter "oHttpConn"

    .prologue
    .line 103
    const-string v0, "Content-Type"

    const-string v1, "application/x-www-form-urlencoded"

    invoke-virtual {p1, v0, v1}, Lcom/glympse/platform/GHttpConnection;->SetRequestProperty(Ljava/lang/String;Ljava/lang/String;)V

    .line 104
    const-string v0, "Content-Length"

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    iget v2, p0, Lcom/glympse/platform/common/ZendeskJob;->m_nContentLength:I

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {p1, v0, v1}, Lcom/glympse/platform/GHttpConnection;->SetRequestProperty(Ljava/lang/String;Ljava/lang/String;)V

    .line 105
    const-string v0, "X-Zendesk-Mobile-API"

    const-string v1, "1.0"

    invoke-virtual {p1, v0, v1}, Lcom/glympse/platform/GHttpConnection;->SetRequestProperty(Ljava/lang/String;Ljava/lang/String;)V

    .line 106
    return-void
.end method

.method public IsSucceeded(I)Z
    .locals 1
    .parameter "nResultCode"

    .prologue
    .line 111
    const/16 v0, 0xc8

    if-eq v0, p1, :cond_0

    .line 112
    const/16 v0, 0xc9

    if-eq v0, p1, :cond_0

    const/4 v0, 0x0

    :goto_0
    return v0

    :cond_0
    const/4 v0, 0x1

    .line 111
    goto :goto_0
.end method

.method public OnComplete(Lcom/glympse/platform/common/JobQueue;)V
    .locals 2
    .parameter "oJobQueue"

    .prologue
    .line 125
    invoke-virtual {p0}, Lcom/glympse/platform/common/ZendeskJob;->DumpDownload()V

    .line 128
    iget v0, p0, Lcom/glympse/platform/common/ZendeskJob;->m_nAttempts:I

    add-int/lit8 v0, v0, 0x1

    iput v0, p0, Lcom/glympse/platform/common/ZendeskJob;->m_nAttempts:I

    .line 132
    iget v0, p0, Lcom/glympse/platform/common/ZendeskJob;->m_nResultCode:I

    invoke-virtual {p0, v0}, Lcom/glympse/platform/common/ZendeskJob;->IsSucceeded(I)Z

    move-result v0

    if-nez v0, :cond_0

    iget v0, p0, Lcom/glympse/platform/common/ZendeskJob;->m_nAttempts:I

    const/4 v1, 0x2

    if-ge v0, v1, :cond_0

    .line 135
    invoke-static {}, Lcom/glympse/platform/Platform;->instance()Lcom/glympse/platform/Platform;

    move-result-object v0

    iget-object v0, v0, Lcom/glympse/platform/Platform;->m_oJobQueue:Lcom/glympse/platform/common/JobQueue;

    invoke-virtual {v0, p0}, Lcom/glympse/platform/common/JobQueue;->AddJob(Lcom/glympse/platform/common/JobQueue$Job;)V

    .line 137
    :cond_0
    return-void
.end method

.method public PreProcess()V
    .locals 0

    .prologue
    .line 97
    invoke-virtual {p0}, Lcom/glympse/platform/common/ZendeskJob;->DumpUpload()V

    .line 98
    return-void
.end method

.method public ProcessResponseHeaders(Lcom/glympse/platform/GHttpConnection;)V
    .locals 1
    .parameter "oHttpConn"

    .prologue
    .line 118
    const-string v0, "Location"

    invoke-virtual {p1, v0}, Lcom/glympse/platform/GHttpConnection;->GetHeaderField(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    iput-object v0, p0, Lcom/glympse/platform/common/ZendeskJob;->m_strLocation:Ljava/lang/String;

    .line 119
    return-void
.end method
